package com.softtek.webbrowser;

import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Manages the Web Browser properties file
 * @author hector.nevarez
 * @see Properties
 */
public class JBProperties extends Properties {
	
	private static final long serialVersionUID = 2734846175927774011L;
	
	private final static File propertiesFile;
	private final static Properties properties;
	
	static
	{
		//TODO: add dinamic file path loading : C:/Workspace/WebBrowser/browser.properties
		propertiesFile = new File("D:/chepech/workspace/Jbird/browser.properties");
		properties = new Properties();
	}
	
	/**
	 * Return an instance of the WebbrowserProperties class only the first time 
	 * its called 
	 * @return a WebbrowserProperties instance (Singleton)
	 */
	public static Properties getProperties(){
		try{
			properties.load(new FileInputStream( propertiesFile ));
		} catch(FileNotFoundException fnfe) {
			System.out.println( fnfe.getMessage() );
		}
		catch(IOException ioe){
			System.out.println( ioe.getMessage() );
		} 
		
		return properties;
	}
	
}
